import publicForm from "@/components/public/el-form.vue"; //弹框form

import {
    saveConcreteChecksample,
    getConcreteChecksampleByFid, //详情
    htgetStationWarnByCompanyId, //获取审核流程
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "fCompanyid",
        "fCompanyname",
        "modelType", "closeType", "keyType"
    ],
    data() {
        return {
            activeNames: ["0"],
            loading: false,
            formData: {},
            sample: "",
            fEquipmentname: [], //已选主要仪器设备
            concretetypeList: [], //泵送混凝土
            concretetypeunList: [], //非泵送混凝土
            RmData: [], //实测平均回弹值Rm
            widthTab: "55",
            widthTab1: "77",
            formLabelWidth: "70px",

            isFetched: false,
            visible: "",
            title: "闭合处理",
            isLock: false,
            btnStatus: [],
            positionObj: [],
            dialogHeight: null,
            activeIndex: "1",


            btnShow: true,
            currentDetail: null,
            fCompanynames: null,
            fCompanyids: null,
            modelTypes: null,
            status: null,
            closeTypes: null,
        };
    },
    components: {
        publicForm,
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        closeType: {
            handler(newVal) {
                if (newVal) {
                    this.closeTypes = newVal


                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        modelType: {
            handler(newVal) {
                if (newVal) {
                    this.modelTypes = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {

                    this.edit(newVal);
                }
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                this.currentDetail = newVal;
            },
            deep: true,
            immediate: true,
        },
        fCompanyid: {
            handler(newVal) {
                if (newVal) {
                    // status:currentRow.fCheckstatus,companyId
                    this.status = newVal.status
                    this.fCompanyids = newVal.companyId

                }
            },
            immediate: true,
        },
        fCompanyname: {
            handler(newVal) {
                if (newVal) {
                    this.fCompanynames = newVal

                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.concretetypeList = JSON.parse(
            sessionStorage.getItem("concretetypeList")
          ); //泵送混凝土
          this.concretetypeunList = JSON.parse(
            sessionStorage.getItem("concretetypeunList")
          ); //非泵送混凝土
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
        this.btnShow = true
        this.getDetail({
            fId: this.currentDetail.fId
        })

        this.getHeight();
    },
    methods: {
        // 折叠面板
        changeCollapse(e) {
            console.log(this.activeNames, e);
        },
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.92 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        selectChange(data, a, b) {
            if (b == "fManufacturername") { //生产厂家
                this.closeFormData.fManufacturername = data.label; //生产厂家
                this.closeFormData.fManufacturerid = data.value //生产厂家id
            } else if (b == "fSuppliername") { //供应商名称
                this.closeFormData.fSuppliername = data.label; //供应商
                this.closeFormData.fSupplierid = data.value //供应商id
            } else if (b == 'fSpecification') {
                this.closeFormData.fSpecification = data.value //供应商id
            }
        },
        edit() {
            this.closeFormData = this.$options.data.call(this).closeFormData;
        },
        // 刪除文件
        delteFile(file, status) {
            var obj;
            var arr;
            if (status == 0) {
                obj = this.closeFormData;
                arr = this.closeFileurllist;
            } else if (status == 1) {
                obj = this.FauditFormData;
                arr = this.FauditFileurllist;
            } else if (status == 2) {
                obj = this.SauditFormData;
                arr = this.SauditFileurllist;
            }
            for (let index = 0; index < arr.length; index++) {
                if (file.uid == arr[index].uid) {
                    if (arr[index].atta == undefined) {
                        obj.recordfiles.push({
                            fId: arr[index].fId,
                        });
                    } else {
                        obj.recordfiles.push({
                            fId: arr[index].atta.fId,
                        });
                    }
                    this.closeFileurllist.splice(index, 1);
                }
            }
        },
        getExamine(data) {
            var status = data.fCheckstatus;
            this.status = data.fCheckstatus;
            htgetStationWarnByCompanyId({
                    fCompanyid: data.fCompanyid
                })
                .then((res) => {
                    if (res.errcode == 0) {

                        var arr = res.data.yjQmpMsCheckEntitywarn.fAduitUser1.split("-");
                        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
                        this.btnShow = true;
                        if ((this.userInfo.companyNature == arr[status])) {
                            if (status == 0) {
                                // 闭合申请单 可编辑
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核
                                this.activeNames = ["0"];
                                // 闭合
                                this.closeFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                // this.closeFormData = this.$options.data.call(this).closeFormData;
                                this.closeFormObj[1].disabled = false;
                                this.closeFormObj[2].disabled = false;
                                // this.closeFormObj[3].disabled = false;
                                this.closeFormObj[4].disabled = false;
                                // 闭合
                                // 一级审核
                                this.FauditFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.SauditFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                //  二级闭合
                                this.closeFormObj[5].uploadSelect = true
                                this.FauditFormObj[4].uploadSelect = false
                                this.SauditFormObj[4].uploadSelect = false
                            } else if (status == 1) {
                                // 一级审核
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = false; //二级审核

                                // 闭合
                                this.closeFormObj.map((item) => {
                                    item.disabled = true;
                                });

                                // 闭合
                                this.firstNum = true; //一级审核
                                // 一级审核
                                this.FauditFormObj.map((item) => {
                                    item.disabled = false;
                                });
                                this.FauditFormObj[2].disabled = true;
                                this.FauditFormObj[3].disabled = true;
                                // 一级审核
                                this.activeNames = ["0", "1"];


                                //  二级闭合
                                this.SauditFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.closeFormObj[5].uploadSelect = false
                                this.FauditFormObj[4].uploadSelect = true
                                this.SauditFormObj[4].uploadSelect = false
                                //  二级闭合

                            } else if (status == 2) {
                                //    二级审核
                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核

                                this.activeNames = ["0", "1", "2"];

                                // 闭合
                                this.closeFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合
                                // 一级审核
                                this.FauditFormObj.map((item) => {
                                    item.disabled = true;
                                });

                                // 一级审核
                                //  二级闭合
                                this.SauditFormObj.map((item) => {
                                    item.disabled = false;
                                });
                                this.SauditFormObj[2].disabled = true;
                                this.SauditFormObj[3].disabled = true;
                                this.closeFormObj[5].uploadSelect = false
                                this.FauditFormObj[4].uploadSelect = false
                                this.SauditFormObj[4].uploadSelect = true
                                //  二级闭合
                            } else if (status == 3) {
                                this.btnShow = false

                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核
                                // 闭合
                                this.closeFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 闭合
                                // 一级审核
                                this.FauditFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                // 一级审核
                                //  二级闭合
                                this.SauditFormObj.map((item) => {
                                    item.disabled = true;
                                });
                                this.closeFormObj[5].uploadSelect = false
                                this.FauditFormObj[4].uploadSelect = false
                                this.SauditFormObj[4].uploadSelect = false
                                //  二级闭合
                            }
                        } else {
                            this.btnShow = false
                            // 闭合
                            this.closeFormObj.map((item) => {
                                item.disabled = true;
                            });
                            // 闭合
                            // 一级审核
                            this.FauditFormObj.map((item) => {
                                item.disabled = true;
                            });
                            // 一级审核
                            //  二级闭合
                            this.SauditFormObj.map((item) => {
                                item.disabled = true;
                            });
                            this.closeFormObj[5].uploadSelect = false
                            this.FauditFormObj[4].uploadSelect = false
                            this.SauditFormObj[4].uploadSelect = false
                            if (status == 0) {
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核

                                //  二级闭合
                            } else if (status == 1) {
                                this.activeNames = ["0"]
                                this.handNum = true; //闭合申请单
                                this.firstNum = false; //一级审核
                                this.secondNum = false; //二级审核

                            } else if (status == 2) {
                                this.activeNames = ["0", "1"]

                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = false; //二级审核

                            } else if (status == 3) {
                                this.activeNames = ["0", "1", "2"]

                                this.handNum = true; //闭合申请单
                                this.firstNum = true; //一级审核
                                this.secondNum = true; //二级审核

                            }
                        }

                        this.closeFormData.aduitStatus = status
                        this.FauditFormData.aduitStatus = status
                        this.SauditFormData.aduitStatus = status
                        // this.closeFormData.aduitStatus = (status - 0) + 1 + "" //按钮 
                        // this.FauditFormData.aduitStatus = (status - 0) + 1 + "" //按钮 
                        // this.SauditFormData.aduitStatus = (status - 0) + 1 + "" //按钮 
                    }
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        // 详情
        getDetail(obj) {
            this.loading = true;

            getConcreteChecksampleByFid(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading = false;
                    if (res.errcode == 0) {
                        var that = this;
                        that.loadingDialog = false;
                        that.formData = res.data.lrCheckConcretesample;

                        that.sample =
                            "样品名称:" +
                            that.formData.fSamplename +
                            "; " +
                            "样品编号:" +
                            that.formData.fSamplingno +
                            "; " +
                            "样品状态:" +
                            that.formData.fSamplespecs +
                            "; ";
                        this.fEquipmentname = this.formData.fEquipmentname;
                        // this.fEquipmentname
                        var data =
                            res.data.lrCheckConcretesample.checkConcretesampleitems;
                        var table =
                            res.data.lrCheckConcretesample.checkConcretesampleresult;
                        var totalData = [];
                        var checkname = [
                            "fParam1",
                            "fParam2",
                            "fParam3",
                            "fParam4",
                            "fParam5",
                            "fParam6",
                            "fParam7",
                            "fParam8",
                            "fParam9",
                            "fParam10",
                            "fParam11",
                            "fParam12",
                            "fParam13",
                            "fParam14",
                            "fParam15",
                            "fParam16",
                        ];
                        var alreadyData = []; //已填的测区
                        for (var i = 0; i < data.length; i++) {
                            for (var j = 0; j < checkname.length; j++) {
                                totalData.push(data[i].fId);
                                if (data[i][checkname[j]] != "") {
                                    alreadyData.push(data[i].fId);
                                }
                            }
                        }
                        var totalId = []; //所有测区Id
                        data.map((item) => {
                            totalId.push(item.fId);
                        });
                        var totalIdIndex = []; //已填测区 index
                        totalId.map((item, index) => {
                            alreadyData.map((i) => {
                                if (item == i) {
                                    totalIdIndex.push(index);
                                }
                            });
                        });
                        let newData = alreadyData.filter(
                            (item, index) => alreadyData.indexOf(item) === index
                        );
                        this.formData.fTestnum = newData.length; // 实测数量(测区)
                        // this.selecttTotalIdIndex = totalIdIndex; //已填测区 index
                        var blankData = [];
                        var rowData = []; //所有数据，不填补零
                        var realArr = []; //每行真实数据
                        for (var c = 0; c < data.length; c++) {
                            var rowDeatil = [];
                            var realData = []; //真实数据
                            for (var h = 0; h < checkname.length; h++) {
                                if (data[c][checkname[h]] != "") {
                                    rowDeatil.push(data[c][checkname[h]]);
                                    realData.push(data[c][checkname[h]]);
                                } else {
                                    blankData.push(c);
                                    rowDeatil.push("0");
                                    // realData.push('0')
                                }
                            }

                            rowData.push({
                                data: rowDeatil,
                            });
                            realArr.push({
                                data: realData,
                            });
                        }
                        // 10个数，去掉三个最大数和三个最小数
                        var drawData = []; // 10个数，去掉三个最大数和三个最小数
                        for (var s = 0; s < realArr.length; s++) {
                            // // 数组对象排序
                            if (realArr[s].data.length == 16) {
                                var sortData = realArr[s].data.sort(function (a, b) {
                                    return a - b;
                                });
                                drawData.push({
                                    data: sortData.slice(3, 13),
                                });
                            } else {
                                drawData.push({
                                    data: realArr[s].data,
                                });
                            }
                        }
                        var angleNum = []; // 四舍五入
                        var anglerealNum = []; //实测平均回弹值Rm数组
                        var cgf = [];
                        var hh = [];
                        drawData.map((item) => {
                            var len = item.data.length;
                            var sum = 0;
                            for (var i = 0; i < len; i++) {
                                var num = item.data[i] - 0;
                                sum += num;
                            }
                            angleNum.push(sum / len);
                            anglerealNum.push(sum / len);
                            cgf.push((sum / len).toFixed(1));
                            hh.push((sum / len).toFixed(1));
                        });
                        anglerealNum.map((items, index) => {
                            var num = "fResult" + (index + 1);
                            if (!isNaN(items)) {
                                this.formData.checkConcretesampleresult[0][num] =
                                    items.toFixed(1);

                                if (table[1][num] == "" && this.formData.fSurface == "侧面") {
                                    table[1][num] = "0°";
                                    data[index].fDetectionangle = "0°";
                                } else if (
                                    table[1][num] == "" &&
                                    (this.formData.fSurface == "表面" ||
                                        this.formData.fSurface == "底面")
                                ) {
                                    table[1][num] = "90°";
                                    data[index].fDetectionangle = "90°";
                                }
                            } else {
                                this.formData.checkConcretesampleresult[0][num] = "";
                                this.formData.checkConcretesampleresult[1][num] = "";
                                this.formData.checkConcretesampleresult[2][num] = "";
                                this.formData.checkConcretesampleresult[3][num] = "";
                                this.formData.checkConcretesampleresult[4][num] = "";
                                this.formData.checkConcretesampleresult[5][num] = "";
                                this.formData.checkConcretesampleresult[6][num] = "";
                                this.formData.checkConcretesampleresult[7][num] = "";
                                table[1][num] = "";
                                data[index].fDetectionangle = "";
                            }
                        });
                        this.formData.checkConcretesampleresult = table;
                        this.RmData = anglerealNum; //实测平均回弹值Rm

                        this.calculationData(
                            this.RmData,
                            this.formData.checkConcretesampleresult
                        );
                    } else {
                        return this.$message.error(res.msg);
                    }
                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }

            });
        },
        calculationData(RmData, data) {
            var numData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
            if (this.formData.fDirection == "非水平方向") {
                // 二、检测角度回弹值修正值
                var angleData = []; //所有角度，未填按'''
                numData.map((item, index) => {
                    var num = "fResult" + (index + 1);

                    angleData.push(data[1][num]);
                });
                // 遍历angleData,得到对应index
                var angleNumBer = [];
                for (var i = 0; i < angleData.length; i++) {
                    if (angleData[i] == "90°") {
                        angleNumBer.push("0");
                    } else if (angleData[i] == "60°") {
                        angleNumBer.push("1");
                    } else if (angleData[i] == "45°") {
                        angleNumBer.push("2");
                    } else if (angleData[i] == "30°") {
                        angleNumBer.push("3");
                    } else if (angleData[i] == "-30°") {
                        angleNumBer.push("4");
                    } else if (angleData[i] == "-45°") {
                        angleNumBer.push("5");
                    } else if (angleData[i] == "-60°") {
                        angleNumBer.push("6");
                    } else if (angleData[i] == "-90°") {
                        angleNumBer.push("7");
                    } else if (angleData[i] == "") {
                        angleNumBer.push("");
                    }
                }
                // 处理实测平均回弹值Rm值
                // 大于等于20，小于等于50
                var angleList = [];
                var dc = [];
                for (var ii = 0; ii < RmData.length; ii++) {
                    if (RmData[ii] < 20) {
                        dc[ii] = 20;
                    } else if (RmData[i] > 50) {
                        dc[ii] = 50;
                    } else if (RmData[i] == "") {
                        dc[ii] = "";
                    } else {
                        dc[ii] = RmData[ii].toFixed(0);
                    }
                    // 对应平均回弹值的所有检测角度
                    angleList.push({
                        data: this.detectionList[dc[ii]],
                    });
                }
                // 根据对应的角度对应值及实测平均回弹值找检测角度回弹值修正值
                var corrected = []; //检测角度回弹值修正值
                for (var j = 0; j < angleList.length; j++) {
                    var ff;
                    if (angleList[j].data != undefined) {
                        for (var ih = 0; ih < angleList[j].data.length; ih++) {
                            ff = angleList[j].data;
                        }
                        corrected.push(ff[angleNumBer[j]]);
                    } else {
                        corrected.push("");
                    }
                }
                // 将检测角度回弹值修正值插入this.formData.checkConcretesampleresult数组
                corrected.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (item != "") {
                        this.formData.checkConcretesampleresult[2][num] = item;
                    }
                });
                // 检测角度回弹值修正值
                // 三、检测角度修正后回弹值
                var reviseAngleNum = [];
                RmData.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (!isNaN(item)) {
                        reviseAngleNum.push(item - 0 + (corrected[i] - 0));
                        this.formData.checkConcretesampleresult[3][num] = (
                            item -
                            0 +
                            (corrected[i] - 0)
                        ).toFixed(1);
                    } else {
                        reviseAngleNum.push("");
                    }
                });
                // 检测角度修正后回弹值
                //  四、浇筑面回弹值修正值
                var PouringSurfaceFalg;
                if (this.formData.fSurface == "表面") {
                    PouringSurfaceFalg = 0;
                } else {
                    PouringSurfaceFalg = 1;
                }
                var reviseAngleNums = [];
                var PouringSurfaceList = [];
                for (var iv = 0; iv < reviseAngleNum.length; iv++) {
                    if (reviseAngleNum[iv] != "") {
                        if (reviseAngleNum[iv] < 20) {
                            reviseAngleNums[iv] = 20;
                        } else if (reviseAngleNum[iv] > 50) {
                            reviseAngleNums[iv] = 50;
                        } else {
                            reviseAngleNums[iv] = (reviseAngleNum[iv] - 0).toFixed(0);
                        }
                    } else {
                        reviseAngleNums[iv] = "";
                    }
                    // 对应检测角度修正后回弹值的浇筑面回弹值修正值
                    PouringSurfaceList.push({
                        data: this.surfaceList[reviseAngleNums[iv]],
                    });
                }
                var PouringSurface = []; //检测角度回弹值修正值
                for (var jj = 0; jj < PouringSurfaceList.length; jj++) {
                    var ll;
                    if (PouringSurfaceList[jj].data != undefined) {
                        for (var iu = 0; iu < PouringSurfaceList[jj].data.length; iu++) {
                            ll = PouringSurfaceList[jj].data;
                        }
                        PouringSurface.push(ll[PouringSurfaceFalg]);
                    } else {
                        PouringSurface.push("");
                    }
                }
                // 将浇筑面回弹值修正值插入this.formData.checkConcretesampleresult数组
                PouringSurface.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (item != "") {
                        this.formData.checkConcretesampleresult[4][num] = item;
                    }
                });
                // 浇筑面回弹值修正值
                // 五、修正后回弹平均值
                var modifiedMean = [];
                reviseAngleNum.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (item != "") {
                        modifiedMean.push((item - 0 + (PouringSurface[i] - 0)).toFixed(1));
                        this.formData.checkConcretesampleresult[5][num] = (
                            item -
                            0 +
                            (PouringSurface[i] - 0)
                        ).toFixed(1);
                    } else {
                        this.formData.checkConcretesampleresult[5][num] = "";
                        modifiedMean.push("");
                    }
                });
                // 五、修正后回弹平均值
                // 浇筑面回弹值修正值
            } else if (this.formData.fDirection == "水平方向") {
                RmData.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (!isNaN(item)) {
                        this.formData.checkConcretesampleresult[5][num] = item.toFixed(1);
                    }
                    this.formData.checkConcretesampleresult[2][num] = "";
                    this.formData.checkConcretesampleresult[3][num] = "";
                    this.formData.checkConcretesampleresult[4][num] = "";
                });
            }

            // 六、碳化深度dm(mm)
            // 六、碳化深度dm(mm)
            //七 强度换算值(MPa)
            var Carbonizationdepth = [];
            numData.map((item, i) => {
                var num = "fResult" + (i + 1);
                Carbonizationdepth.push(data[6][num]);
            });

            var reallCarbonizationdepth = [];
            var reallCarbonizationv = [];
            RmData.map((item, index) => {
                //获取有实测平均回弹值Rm，且碳化深度dm(mm)不为空的数据
                if (!isNaN(item)) {
                    reallCarbonizationdepth.push(Carbonizationdepth[index]);
                    reallCarbonizationv.push(Carbonizationdepth[index]);
                } else {
                    reallCarbonizationdepth.push("");
                }
            });
            var carbonationDepthNumBer = [];
            for (var ir = 0; ir < reallCarbonizationdepth.length; ir++) {
                if (reallCarbonizationdepth[ir] == "0.0") {
                    carbonationDepthNumBer.push("0");
                } else if (reallCarbonizationdepth[ir] == "0.5") {
                    carbonationDepthNumBer.push("1");
                } else if (reallCarbonizationdepth[ir] == "1.0") {
                    carbonationDepthNumBer.push("2");
                } else if (reallCarbonizationdepth[ir] == "1.5") {
                    carbonationDepthNumBer.push("3");
                } else if (reallCarbonizationdepth[ir] == "2.0") {
                    carbonationDepthNumBer.push("4");
                } else if (reallCarbonizationdepth[ir] == "2.5") {
                    carbonationDepthNumBer.push("5");
                } else if (reallCarbonizationdepth[ir] == "3.0") {
                    carbonationDepthNumBer.push("6");
                } else if (reallCarbonizationdepth[ir] == "3.5") {
                    carbonationDepthNumBer.push("7");
                } else if (reallCarbonizationdepth[ir] == "4.0") {
                    carbonationDepthNumBer.push("8");
                } else if (reallCarbonizationdepth[ir] == "4.5") {
                    carbonationDepthNumBer.push("9");
                } else if (reallCarbonizationdepth[ir] == "5.0") {
                    carbonationDepthNumBer.push("10");
                } else if (reallCarbonizationdepth[ir] == "5.5") {
                    carbonationDepthNumBer.push("11");
                } else if (reallCarbonizationdepth[ir] == "≥6.0") {
                    carbonationDepthNumBer.push("12");
                } else if (reallCarbonizationdepth[ir] == "") {
                    carbonationDepthNumBer.push("");
                }
            }
            // 判断测区强度换算表，
            var AverageArr = []; //修正后回弹平均值
            numData.map((item, i) => {
                var num = "fResult" + (i + 1);
                AverageArr.push(this.formData.checkConcretesampleresult[5][num]);
            });

            var newAverageArr = []; //修正后回弹平均值(修正值自我)
            var correctedAveraged = []; //强度换算值(MPa)数组
            var correctedAveragedData = [];
            if (this.formData.fConcretetype == "泵送混凝土") {
                // 大于等于18.6，小于等于52.8
                var correctedAverageList = [];
                for (var id = 0; id < AverageArr.length; id++) {
                    if (AverageArr[id] != "") {
                        if (AverageArr[id] - 0 < 18.6) {
                            newAverageArr[id] = 18.6;
                        } else if (AverageArr[id] - 0 > 52.8) {
                            newAverageArr[id] = 52.8;
                        } else {
                            newAverageArr[id] = (AverageArr[id] - 0).toFixed(1);
                        }
                    } else {
                        newAverageArr[id] = "";
                    }
                    // 对应平均回弹值的所有换算强度
                    correctedAverageList.push({
                        data: this.concretetypeList[newAverageArr[id]],
                    });
                }
                for (var jb = 0; jb < correctedAverageList.length; jb++) {
                    var vf;
                    if (correctedAverageList[jb].data != undefined) {
                        for (var ik = 0; ik < correctedAverageList[jb].data.length; ik++) {
                            vf = correctedAverageList[jb].data;
                        }
                        if (vf[carbonationDepthNumBer[jb]] != undefined) {
                            correctedAveraged.push(vf[carbonationDepthNumBer[jb]]);
                            correctedAveragedData.push(vf[carbonationDepthNumBer[jb]]);
                        } else {
                            correctedAveraged.push("");
                            correctedAveragedData.push("");
                        }
                    } else {
                        correctedAveraged.push("");
                        correctedAveragedData.push("");
                    }
                }
                correctedAveraged.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (item != "") {
                        this.formData.checkConcretesampleresult[7][num] = item;
                    }
                });
            } else if (this.formData.fConcretetype == "非泵送混凝土") {
                var correctedAverageLists = [];
                for (var ids = 0; ids < AverageArr.length; ids++) {
                    if (AverageArr[ids] != "") {
                        if (AverageArr[ids] < 20.0) {
                            newAverageArr[ids] = "20.0";
                        } else if (AverageArr[ids] > 50.0) {
                            newAverageArr[ids] = "50.0";
                        } else {
                            newAverageArr[ids] = AverageArr[ids];
                        }
                    } else {
                        newAverageArr[ids] = "";
                    }
                    correctedAverageLists.push({
                        data: this.concretetypeunList[newAverageArr[ids]],
                    });
                }

                for (var jr = 0; jr < correctedAverageLists.length; jr++) {
                    var vfs;
                    if (correctedAverageLists[jr].data != undefined) {
                        for (var io = 0; io < correctedAverageLists[jr].data.length; io++) {
                            vfs = correctedAverageLists[jr].data;
                        }
                        if (vfs[carbonationDepthNumBer[jr]] != undefined) {
                            correctedAveraged.push(vfs[carbonationDepthNumBer[jr]]);
                            correctedAveragedData.push(vfs[carbonationDepthNumBer[jr]]);
                        } else {
                            correctedAveraged.push("");
                            correctedAveragedData.push("");
                        }
                    } else {
                        correctedAveraged.push("");
                        correctedAveragedData.push("");
                    }
                }
                correctedAveraged.map((item, i) => {
                    var num = "fResult" + (i + 1);
                    if (item != "") {
                        this.formData.checkConcretesampleresult[7][num] = item;
                    }
                });
            }
            // this.formData.checkConcretesampleresult.map()
            // 强度换算值(MPa)
            // 碳化深度dm(mm)
            var correctedAveragedNum = []; //处理强度换算值
            for (var ig = 0; ig < correctedAveragedData.length; ig++) {
                // /\D/g
                var str = correctedAveragedData[ig].replace(/[^\d.]/gi, "");
                correctedAveragedNum.push(str);
            }
            var correctedAveragedNumber = 0;
            for (i = 0; i < correctedAveragedNum.length; i++) {
                var num = correctedAveragedNum[i];

                correctedAveragedNumber += num - 0;
            }
            var correctedGetData = [];
            correctedAveragedNum.map((item) => {
                if (item != "") {
                    correctedGetData.push(item);
                }
            });
            var strengthConversionAverage; // 强度换算值平均值
            if (correctedGetData.length != 0) {
                strengthConversionAverage =
                    correctedAveragedNumber / correctedGetData.length; // 强度换算值平均值
            } else {
                strengthConversionAverage = 0;
            }
            //  强度换算值方差
            var strengthConversionNum = 0;
            // 强度换算值减去强度换算值平均值 的平方
            for (var ie = 0; ie < correctedGetData.length; ie++) {
                if (correctedGetData[ie] != "") {
                    strengthConversionNum += Math.pow(
                        correctedGetData[ie] - 0 - strengthConversionAverage.toFixed(2),
                        2
                    );
                }
            }
            const filtered = reallCarbonizationv.filter((item) => {
                return item !== null && typeof item !== "undefined" && item !== "";
            });
            if (filtered.length != 0) {
                //碳化深度dm(mm)数组不为空时
                var strengthAveraged = 0;
                if (correctedGetData.length != 0 && correctedGetData.length != 1) {
                    strengthAveraged =
                        strengthConversionNum / (correctedGetData.length - 1);
                }
                var strengthAveragedNum = Math.sqrt(strengthAveraged);
                this.formData.fStandarddeviation = strengthAveragedNum.toFixed(2);
                //  强度换算值方差
                // 混凝土强度推定值(MPa)
                console.log(
                    correctedGetData,
                    correctedAveragedNum,
                    this.formData.fTestnum
                );
                if (this.formData.fTestnum - 0 < 10) {
                    this.formData.fConcreteresult = correctedGetData[0];
                    for (var ifn = 1; ifn < correctedGetData.length; ifn++) {
                        this.formData.fConcreteresult = Math.min(
                            this.formData.fConcreteresult,
                            correctedGetData[ifn]
                        );
                    }
                    this.formData.fConcreteresult = this.formData.fConcreteresult + "Mpa";
                } else if (this.formData.fTestnum - 0 >= 10) {
                    //当构件测区不少于10个时
                    this.formData.fConcreteresult =
                        (
                            strengthConversionAverage -
                            this.formData.fStandarddeviation * 1.645
                        ).toFixed(1) + "Mpa";
                }
                for (var ia = 0; ia < correctedGetData.length; ia++) {
                    if (correctedGetData[ia] - 0 < 10.0) {
                        this.formData.fConcreteresult = "<10.0Mpa"; //当构件的测区强度值中有小于10.0MPa时
                    }
                    if (this.formData.fTestresult == null) {
                        this.formData.fTestresult =
                            "经检测，该结构物回弹强度推定值" +
                            this.formData.fConcreteresult +
                            "。";
                    } else {
                        this.formData.fTestresult =
                            "经检测，该检测结果符合（判定依据）技术要求。";
                    }
                    // 混凝土强度推定值(MPa)
                }
            }
            if (this.formData.fModifydate == null) {
                this.saveForm(this.formData);
            }
        },

        // 保存
        saveForm(obj) {
            this.loading = true;
            this.isLock = true
            saveConcreteChecksample(obj)
                .then((res) => {
                    if (res.errcode == 0) {
                        console.log(88);
                    }
                })
                .catch((error) => {
                    console.log("拌合站设置-新增）", error);
                });
        },
    },
};